package com.admin.controller;


import com.common.domain.entity.ResponseResult;
import com.common.domain.entity.Role;
import com.common.domain.entity.RoleRequest;
import com.common.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("system/role")
public class RoleController {

    @Autowired
    private RoleService roleService;

    @GetMapping("list")
    public ResponseResult AllRole(Integer pageNum,Integer pageSize,String roleName,String status){
        return roleService.getAllRole(pageNum,pageSize,roleName,status);
    }

    @PutMapping("changeStatus")
    public ResponseResult changeStatus(@RequestBody RoleRequest roleRequest){
        return roleService.changeStatus(roleRequest);
    }

    @PostMapping
    public ResponseResult insertRole(@RequestBody Role role){
        return roleService.insertRole(role);
    }

    @GetMapping("{id}")
    public ResponseResult getRole(@PathVariable Long id){
        return roleService.getRole(id);
    }

    @PutMapping
    public ResponseResult updateRole(@RequestBody Role role){
        return roleService.updateRole(role);
    }

    @DeleteMapping("{id}")
    public ResponseResult deleteRole(@PathVariable Long id){
        return roleService.deleteRole(id);
    }

    @GetMapping("listAllRole")
    public ResponseResult listAllRole(){
        return  roleService.listAllRole();
    }
}
